home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / lang / c-part1 / 7260 < prev    next >
Encoding:
Internet Message Format  |  1996-08-05  |  2.2 KB

  1. Path: pegasus.montclair.edu!harmon
  2. From: harmon@pegasus.montclair.edu (Derek Harmon)
  3. Newsgroups: comp.lang.c
  4. Subject: Re: What wrong!
  5. Date: 13 Feb 1996 18:19:55 -0500
  6. Organization: Montclair State University
  7. Message-ID: <harmon.824252266@pegasus.montclair.edu>
  8. References: <4fpa2g$ebg@ratree.psu.ac.th>
  9. NNTP-Posting-Host: pegasus.montclair.edu
  10. X-Newsreader: NN version 6.5.0 #68 (NOV)
  11.  
  12. s3610165@maliwan.psu.ac.th (Sanon CHAOCHAIYAPORN) writes:
  13. >will clear and appear dos prompt but it is not follow that. My program will 
  14. >appear error message,"BGI Error: Graphics not initialized (use'initgraph')".
  15.                        ^\_ Borland Graphics Interface (MS-DOS specific)
  16.  
  17. >Who can help me? Please, advice to me...
  18.  
  19.    As this is specific to Borland's graphics.h, you would have better luck
  20. asking in comp.os.msdos.programmer or rec.games.programmer.
  21.  
  22. >  int gd = DETECT;
  23. >  int gm = getgraphmode();
  24.             ^^^^^!^^^^^^^^
  25.    Your error no doubt occurs here.  You call initgraph() later on in your
  26. program, but this is the 2nd line that gets executed.  initgraph() must be
  27. called before any other BGI functions.  It is alright for gm to be uninit-
  28. ialized when you make a call to initgraph(), it is part of initgraph()'s
  29. responsibilities to initialize gm for you.  Replace with,
  30.  
  31. :  int gm;
  32.  
  33. and your program will run.  It would also be wise to use graphresult()
  34. after initgraph() and test for grOK, in case initgraph() fails for any
  35. reason.
  36.  
  37. > clrscr();   /* this is not necessary, initgraph() will clear everything */
  38. > initgraph(&gd,&gm,"c:\\winapp\\tc");
  39. : if (graphresult() != grOk) {
  40. :    puts("Graphics Error.");
  41. :    exit(1);
  42. : } /* it'd be even better to save graphresult() to a variable and then
  43. :    * print grapherrormsg(). */
  44.  
  45. > do
  46. > {
  47. >     initgraph(&gd,&gm,"c:\\winapp\\tc");
  48.  
  49.    Oh, and something bad will probably happen if you leave this in here, you
  50. shouldn't call initgraph() more than once in an application.
  51.  
  52.                                                 -- Stone
  53. --
  54. # Derek Harmon (aka Stonelight)    harmon@pegasus.montclair.edu
  55. # - Computer Science Undergrad, Montclair State University, NJ
  56. # - My views are my own, nobody else is this creative.  3;)>
  57. ... Buy land today, it's not being made anymore.
  58.